package xyz.yuzegod.megawalls.listener;

import org.bukkit.event.EventHandler;
import org.bukkit.event.server.ServerListPingEvent;
import xyz.yuzegod.megawalls.MegaWalls;
import xyz.yuzegod.megawalls.game.Game;
import xyz.yuzegod.megawalls.game.GameState;

public class ServerListener extends BaseListener
{
    private final Game game;
    
    public ServerListener(final MegaWalls plugin) {
        super(plugin);
        this.game = plugin.getGame();
    }
    
    @EventHandler
    public void onServerListPing(final ServerListPingEvent e) {
        if (this.game != null) {
            final GameState state = this.game.getState();
            if (state == GameState.LOBBY) {
                e.setMotd("Waiting");
            }
            else if (state == GameState.INGAME) {
                e.setMotd("§c游戏中");
            }
            else if (state == GameState.STOP) {
                e.setMotd("§c已结束");
            }
        }
    }
}
